package com.lifeverse.event;

import lombok.Data;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * 生命体事件基类
 */
@Data
public abstract class LifeEntityEvent {
    
    /**
     * 事件ID
     */
    private String eventId;
    
    /**
     * 事件类型
     */
    private String eventType;
    
    /**
     * 源生命体ID
     */
    private Long sourceEntityId;
    
    /**
     * 目标生命体ID（可选）
     */
    private Long targetEntityId;
    
    /**
     * 事件时间戳
     */
    private LocalDateTime timestamp;
    
    /**
     * 事件数据
     */
    private Map<String, Object> eventData;
    
    /**
     * 事件优先级
     */
    private EventPriority priority = EventPriority.NORMAL;
    
    /**
     * 事件来源
     */
    private String source;
    
    /**
     * 事件版本
     */
    private String version = "1.0";
    
    public LifeEntityEvent() {
        this.eventId = java.util.UUID.randomUUID().toString();
        this.timestamp = LocalDateTime.now();
    }
    
    public LifeEntityEvent(String eventType, Long sourceEntityId) {
        this();
        this.eventType = eventType;
        this.sourceEntityId = sourceEntityId;
    }
    
    /**
     * 事件优先级枚举
     */
    public enum EventPriority {
        LOW(1),
        NORMAL(2),
        HIGH(3),
        URGENT(4),
        CRITICAL(5);
        
        private final int level;
        
        EventPriority(int level) {
            this.level = level;
        }
        
        public int getLevel() {
            return level;
        }
    }
}